#!/bin/bash
set -e

if [ not -d $CODESPACE ]; then
    echo "找不到openGauss-server代码目录。配置 export CODESPACE=/xx/xx/openGauss-server"
    exit 1
fi

extension_dir=$CODESPACE/contrib/devinsight

echo "rm $extension_dir -fr"
rm $extension_dir -fr

echo "mkdir $extension_dir"
mkdir $extension_dir

echo "cp ./* $extension_dir/ -r"
cp ./* $extension_dir/ -r

echo "cd $extension_dir"
cd $extension_dir

echo "make && make install"
make -sj
make install

cd -


echo "create command:"
echo "    create extension devinsight;"
echo "    select devinsight();"
